package cn.yuhh.service.impl;

import cn.yuhh.dao.IFoodTypeDao;
import cn.yuhh.dao.impl.FoodTypeDao;
import cn.yuhh.entity.FoodType;
import cn.yuhh.factory.BeanFactory;
import cn.yuhh.service.IFoodTypeService;
import org.junit.Test;

import java.util.List;

/**
 * Created by Brill on 2016/12/10.
 */
public class FoodTypeService implements IFoodTypeService {

    private IFoodTypeDao dao = BeanFactory.getInstance("foodTypeDao", FoodTypeDao.class);

    @Override
    public void add(FoodType foodType) {
        dao.add(foodType);
    }

    @Override
    public void delete(int id) {
        dao.delete(id);
    }

    @Override
    public void update(FoodType ft) {
        dao.update(ft);
    }

    @Override
    public List<FoodType> query() {
        return dao.query();
    }

    @Override
    public FoodType findById(int id) {
        return dao.findById(id);
    }

    @Override
    public List<FoodType> query(String keyword) {
        return dao.query();
    }

    @Override
    public Integer getFistType() {
        return null;
    }
    @Test
    public void addTest() {
        FoodType foodType = new FoodType();
        foodType.setTypeName("湘菜");
        dao.add(foodType);

        List<FoodType> types = dao.query();
        for (FoodType type :
                types) {
            System.out.println(type);
        }
    }
}
